
#pragma once

#define KINDID_GENERIC_SINGLE 0xf0000001
#define KINDID_GENERIC_ARRAY 0xf0000002
#define KINDID_GENERIC_DICTIONARY 0xf0000003

namespace ReloadUdpCall
{
	class ReloadSecurityBlock;

	class Kind
	{
	public:
		Kind();
		virtual ~Kind();

		//Each kind has either an id attribute or a name attribute.
		KindId										kindId_;//the id is an integer kind-id allocated out of private space.
		std::string									kindName_;//The name attribute is a string representing the kind (the name registered to IANA)

		std::size_t									maxCount_;//the maximum number of values which members of the overlay must support.

		DataModel									dataModel_;//the data model to be used.

		std::size_t									maxSize_;//the maximum size of individual values.

		AccessControlPolicy							accessControl_;//the access control model to be used.

		std::size_t									maxNodeMultiple_;	//This is optional and only used when the access
																		//control is NODE-MULTIPLE. This indicates the maximum value for
																		//the i counter. This is an integer greater than 0.
	};

	class KindBlock
	{
	public:
		KindBlock();
		virtual ~KindBlock();

		Kind										kind_;
		ReloadSecurityBlock							kindSignature_;	//This signature is computed across the kind from the beginning of the
																	//first < of the kind to the end of the last > of the kind
	};

	class OverlayConfiguration
	{
	public:
		OverlayConfiguration();
		virtual ~OverlayConfiguration();
		
		std::string									instanceName_;//name of the overlay

		uint16							sequence_;//a monotonically increasing sequence number between 0 and 2^16-2

		OverlayAlgorithmTypeT						topologyPlugin_;//This element defines the overlay algorithm being used.
																	//If missing the default is "CHORD-RELOAD".

		byte								nodeIdLength_;	//This element contains the length of a NodeId (NodeIdLength) in bytes.
																	// This value MUST be between 16 (128 bits) and 20 (160 bits). 
																	//If this element is not present, the default of 16 is used.

		uint32							chordUpdateInterval_;//The update frequency for the Chord-reload topology plugin

		uint32							chordPingInterval_;//The ping frequency for the Chord-reload topology plugin

		uint32							chordReactive_;	//Whether reactive recovery should be used for this
																	//overlay. Set to "true" or "false". Default if missing is "true".

		std::size_t									maxMessageSize_;	//Maximum size in bytes of any message in the
																		//overlay. If this value is not present, the default is 5000.

		uint8								initialTtl_;//Initial default TTL for messages. If this value is not present, the default is 100.

		boost::unordered_map<KindId, KindBlock>		requiredKinds_;	//This element indicates the kinds that members must support
																	//and contains multiple kind-block elements that each define a single
																	//kind that MUST be supported by nodes in the overlay.
	};

	const OverlayConfiguration overlayConfiguration_;
}
